package xml1201;

import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


public class dom4j {
public static void main(String[] args) throws DocumentException {
	SAXReader reader = new SAXReader();
	Document document = reader.read("D4.xml");
	Element root = document.getRootElement();
	List<Element> elements = root.elements("brand");
	for (Element element : elements) {
		System.out.println(element.getName());
		String name = element.attributeValue("name");
		String pinyin = element.attributeValue("pinyin");
		System.out.println(name + pinyin);
       
		List<Element> types = element.elements("type");
		for (Element element2 : types) {
			System.out.println(element2.attributeValue("name"));
		}

	}

}
}
